package com.lmb.controller;

import com.lmb.bean.PublicServices;
import com.lmb.mapper.PublicServicesDao;
import com.lmb.service.PublicServicesService;
import com.lmb.util.Page;
import com.lmb.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/public")
public class PublicServicesController {
    @Autowired
    PublicServicesDao publicServicesDao;
    @Autowired
    PublicServicesService publicServicesService;
    @PostMapping
    public Result add(@RequestBody PublicServices publicServices)
    {
        Object obj=publicServicesService.add(publicServices);
        return Result.success(obj);
    }
    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj=publicServicesService.del(id);
        return Result.success(obj);
    }
    @PutMapping
    public Result edit(@RequestBody PublicServices publicServices){
        Object obj=publicServicesService.edit(publicServices);
        return Result.success(obj);
    }
    @GetMapping("all")
    public Result all( PublicServices publicServices){
        Object obj=publicServicesService.all(publicServices);
        return Result.success(obj);
    }
    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=publicServicesService.one(id);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page, PublicServices publicServices){
        publicServicesService.page(page,publicServices);
        return Result.success(page);
    }
}
